import Vue from 'vue'
// import wx from 'weixin-js-sdk'
/* eslint-disable */
function wxConfig() {
  let url = window.location.href
  Vue.axiosPost(Vue.api.wxAuthURL, {url: url}).then((r) => {
    if (r.code == '0000') {
      var res = r.data;
      Vue.wx.config({
        debug: false,
        appId: res.appId,
        timestamp: res.timestamp,
        nonceStr: res.noncestr,
        signature: res.signature,
        jsApiList: [
          'scanQRCode',
          'getLocation',
          'addCard',
          'openLocation',
          'getLocation'
        ]
      });
    } else {
      alert('微信授权异常！');
    }
  })
}

let ua = window.navigator.userAgent
if (/MicroMessenger/i.test(ua)) {
  Vue.prototype.$wx = window.wx
  Vue.wx = window.wx
  wxConfig()
}

/* eslint-enable */
